



# Input: A file that contains English words,
# where each word is separated from next word on a line by one space,
# specified on the command line.


# Output: A table, in which the first column has the unique words. 
# From the input file and second column has the no. of times the word appeared in the file; no word can appear twice in the table.

print "plese give the input text from commandprompt \n";

#main loop to get and process lines of input text
  
while (<>)     
{

#spilt the line into words
@line_words = split /[\.,; :!\?]\s*/;
#>>> loop count the words (either increment or initialize to 1

foreach $word (@line_words)
{
if(exists $freq{$word} )
{
$freq{$word}++;
}
else {
$freq{$word} = 1;
}
}
}
#>>> displayint words and there frequencies
print "\n word \t\t  frequency\n\n";
foreach $word ( sort keys %freq ) 
{
print " $word  ----------------> $freq{$word} \n " ;
} 



